<template>
    <view style="padding: 15px;">
        <u-form ref="validateFormRef" :model="validateForm.value" :label-width="200">
            <u-form-item label="处理说明" prop="remark" required>
                <u-input type="textarea" height="40" v-model="validateForm.value.remark" placeholder="请输入处理说明"/>
            </u-form-item>
        </u-form>

        <u-button type="error" @click="submit">提交</u-button>
    </view>
</template>

<script>
    import {CommonUtil} from "@/dev/core/utils/common.util";
    import {TbFeedbackService} from "@/dev/services/tb-feedback.service";

    export default {
        data() {
            return {
                fileList: [],
                validateForm: {
                    value: {
                        id: CommonUtil.randomUUID(),
                        isHandled: '1',
                        remark: '',
                    },
                    rules: {
                        remark: [
                            {required: true, message: '必填项!', trigger: ['change', 'blur']},
                            {pattern: /^(?=.*\S).+$/, message: '必填项!', trigger: ['change', 'blur']},
                        ],
                    }
                }
            }
        },
        onReady() {
            const _self = this;
            this.validateForm.value.id = this.objParams.id;
        },
        methods: {
            submit() {
                const _self = this;
                this.$refs.validateFormRef.validate(valid => {
                    if (valid) {
                        console.log('验证通过', _self.validateForm.value);
                        CommonUtil.alert({
                            title: '提示！',
                            content: '确认提交吗？',
                            showCancel: true, // 是否显示取消按钮
                            success: function (res) {
                                if (res.cancel) { // 点击取消,默认隐藏弹框
                                } else { // 点击确定
                                    new TbFeedbackService().updateTbFeedback(_self.validateForm.value).then(result => {
                                        CommonUtil.toastNavigateBack('处理成功');
                                    });
                                }
                            }
                        });
                    } else {
                        console.log('验证失败');
                    }
                });
            }
        }
    };
</script>

<style lang="scss" scoped>
</style>
